package com.addcn.pushlibrary.oppo
import android.app.Application
import android.content.Context
import android.util.Log
import com.addcn.pushlibrary.LConfiguration
import com.addcn.pushlibrary.utils.LRomUtil
import com.heytap.msp.push.HeytapPushManager
import com.heytap.msp.push.callback.ICallBackResultService


/**
 * author:luwenbo
 * created on date : 2019-06-06
 * content:
 * describe:
 */

class LOppoManger{
    companion object{
        var TAG = "LOppoManger"
        fun init(application: Application, configuration: LConfiguration?) {
            HeytapPushManager.init(application,configuration!!.isDebug)
            register(application.applicationContext,configuration.oppoAppKey,configuration.oppoAppSercet)
            HeytapPushManager.requestNotificationPermission()
            Log.i(TAG, "==isSupportPush:" + isSupportPush())
        }

        fun startPush(context: Context) {
            HeytapPushManager.resumePush()
        }

        fun stopPush(context: Context) {
            HeytapPushManager.pausePush()
        }

        fun setTag(context: Context){
            //HMSAgent.Push.
        }
        fun isSupportPush():Boolean{
            return HeytapPushManager.isSupportPush()
        }

        fun register(context: Context,appKey:String,appSecret:String){
             HeytapPushManager.register(context,appKey,appSecret,object :ICallBackResultService{
                 override fun onGetPushStatus(code: Int, status: Int) {
                     Log.i(TAG, "==onGetPushStatus:" )
                 }

                 override fun onSetPushTime(code: Int, s: String?) {
                     Log.i(TAG, "==onSetPushTime:" )
                 }

                 override fun onGetNotificationStatus(code: Int, status: Int) {
                     Log.i(TAG, "==onGetNotificationStatus:" )
                 }

                 override fun onUnRegister(code: Int) {
                     Log.i(TAG, "==onUnRegister:" )
                 }

                 override fun onRegister(code: Int, oppoToken: String?) {
                     Log.i(TAG, "==onRegister:code#${code} oppoToken#${oppoToken}" )
                 }

             })
        }

        fun unRegister(){
            HeytapPushManager.unRegister()
        }

        fun getRegisterId():String{
            if (HeytapPushManager.getRegisterID() == null){
                return ""
            }
           return HeytapPushManager.getRegisterID()
        }

        fun getNotificationStatus(){
            HeytapPushManager.getNotificationStatus()
        }
    }

}